package team.future.joke.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import team.future.joke.constant.StatusConstants;
import team.future.joke.crawler.Haha365Crawler;
import team.future.joke.entity.Joke;
import team.future.joke.service.JokeService;

/**
 * Title: TestController.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月1日 下午8:12:05 <br>
 * @author futurezhu
*/
@Controller
public class TestController {

	@Autowired
	private JokeService jokeService;

	@RequestMapping("/test")
	@ResponseBody
	public String test() {
		/*Joke j = jokeService.getJokeByTitle("还是很有把握的");
		jokeService.insertJoke(makeJoke());*/
		/*Haha365PageCrawler c = new Haha365PageCrawler();
		Haha365Crawler c1 = new Haha365Crawler();
		try {
			c.run();
			c1.run();
		} catch (Exception e) {
			e.printStackTrace();
		}*/
		//return SecurityUtil.encode("zw") + "!" + SecurityUtil.decode(SecurityUtil.encode("zw"));
		Haha365Crawler c1 = new Haha365Crawler();
		try {
			c1.run();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	private Joke makeJoke() {
		Joke j = new Joke();
		j.setContent("123");
		j.setStatus(StatusConstants.STATUS_JOKE_NORMAL);
		j.setType(StatusConstants.TYPE_JOKE_DEFAULT);
		j.setTitle("111");
		j.setTime(new Date());
		return j;
	}
}
